package com.woniuxy.dr_mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.dr_mall.entity.DrCategory;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
public interface DrCategoryMapper extends BaseMapper<DrCategory> {

    @Select("select * from dr_category")
    List<DrCategory> getAll();

    @Insert("insert into dr_category(name,status,guide,sort) values(#{name},#{status},#{guide},#{sort})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void addCategory(DrCategory drCategory);

    @Select("select * from dr_category where id = #{id}")
    DrCategory getById(@Param("id") int id);

    @Update("update dr_category set status='n' where id = #{id}")
    void delById(int id);

    @Select("select * from dr_category where name = #{name}")
    DrCategory getByName(@Param("name") String name);

}
